package edu.gdin.ecommerce.dao;

import org.springframework.stereotype.Repository;

import edu.gdin.ecommerce.model.CardIssuer;
import edu.gdin.ecommerce.util.Pager;

@Repository("cardIssuerDAO")
public class CardIssuerDAO extends BaseDAO {
	
	public Pager queryIssuers(CardIssuer is, int cPage){
		
		String hql = "from CardIssuer p where 1=1";
		
		String name = is.getName();
		Integer status = is.getStatus();
		String address = is.getAddress();
		String flag = is.getCardFlag();
		String mobile = is.getMobile();
		String desc = is.getCardIssuerDesc();
		String tel = is.getTel();
		
		hql += name==null || name.equals("") ? "" : " and p.name like '%" + name + "%'";
		hql += status==null || status==-1 ? "" : " and p.status =" + status+" ";
		hql += address == null || address.equals("")? "" : " and p.address like '%" + address +"%'";
		hql += flag == null || flag.equals("")? "" : " and p.cardFlag like '%" + flag +"%'";
		hql += mobile == null || mobile.equals("")? "" : " and p.mobile like '%" + mobile +"%'";
		hql += tel == null || tel.equals("")? "" : " and p.tel like '%" + tel +"%'";
		hql += desc == null || desc.equals("")? "" : " and p.cardIssuerDesc like '%" + desc +"%'";
		
		
		return this.getPage(hql, cPage);
	}
	
}
